<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
namespace App\Admin\Actions\Form;

use App\Models\MemberTopupOrder;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;

class MemberTopoupOrderRejectForm extends Form implements LazyRenderable
{
    use LazyWidget;

    /*
     * Handle the form request.
     *
     * @param array $input
     *
     * @return mixed
     */
    use LazyWidget;

    public function handle(array $input)
    {
        $id = $input['id'];
        $message = $input['message'];
        $u = MemberTopupOrder::query()->findOrFail($id);

        $u->message = $message;
        $u->review = 2;
        $u->save();

        return $this->response()
            ->success('已驳回（原因：' . $message . '）')
            ->refresh();
    }

    /**
     * Build a form here.
     */
    public function form()
    {
        $this->text('message', '消息')->required();
        //批量选择的行的值怎么传递看下面
        $this->hidden('id')->default($this->payload['id']);
    }

    /**
     * The data of the form.
     *
     * @return array
     */
    public function default()
    {
        //设置默认值
        return [
        ];
    }
}
